﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;

namespace ClassLibrary.DAO
{
    public class TblMenuItemDAO
    {
         private DBService _db = null;
         public TblMenuItemDAO(string ConnectionString)
         {
            _db = new DBService(ConnectionString);
         }

         public DataTable GetMenuItem_All()
         {
             DataTable dt = new DataTable();
             try
             {
                 dt = _db.ExeSP_DataTable("Select * from TblMenuItem", false, CommandType.Text);
             }
             catch (Exception ex)
             {
                 throw ex;
             }

             return dt;

         }

         public DataTable GetMenuItem_ByIDMenu(int IDMenu)
         {
             DataTable dt = new DataTable();
             try
             {
                 dt = _db.ExeSP_DataTable("Select * from TblMenuItem where ID = @IDMenu",
                     new string[]{"@IDMenu"},
                     new object[]{IDMenu}, CommandType.Text);
             }
             catch (Exception ex)
             {
                 throw ex;
             }

             return dt;

         }

         public DataTable GetMenuItem_ByName_ID(int IDMenu)
         {
             DataTable dt = new DataTable();
             try
             {
                 dt = _db.ExeSP_DataTable("Select * from TblMenuItem where ID = @IDMenu and MenuItemName not in ('SEM', 'LAN TRUYEN','SANG TAO', 'EMAIL', 'DISPLAY ADS','WEB DESIGN', 'DISPLAY ADS','ANALYTICS','CONTACT US' )",
                     new string[] { "@IDMenu" },
                     new object[] { IDMenu}, CommandType.Text);
             }
             catch (Exception ex)
             {
                 throw ex;
             }

             return dt;
         }
    }
}
